<template>
	<view>
		<view class="prompt-box-popup">
			<!-- <view class="container">
				<view class="carousel-section">
					<view class="titleNview-background"  :style="'background: url('+url+'/wximg/bjTop1.png'+'); background-size: 100%;'"  ></view>
					<view class="content" :style="{height: heightContent +'px'}">
						<view class="tableBox">
							<view class="tabletitle">转出包裹信息</view>
							<view class="table">
								<wyb-table 
								:key="key"
								checker-cell-bg-color="#fff"  
								checker-color="#107e62" 
								show-vert-border="false" 
								header-bg-color="#fff" 
								first-col-bg-color="#fff" 
								 content-bg-color="#fff"
								 content-ft-color="#333333" 
								 header-weight="true" 
								 border-color="#ffffff"
								 ref="table" 
								 :headers="headers2" 
								 :contents="contents2" 
								 width="100%"
								 :show-vert-border="vertborder"
								:loading="loading"
								  />
							</view>
							<view class="total">总计：{{sum}}包</view>
						</view>
					</view>
				</view>
				
			</view> -->
			<view class="popup-info">
				<view class="popuptitle">{{username}}调配信息</view>
				<view class="tableBox">
					<view class="tabletitle">{{AuthorizationList}}</view>
					<view class="table">
						<wyb-table 
						:key="key"
						show-vert-border="false" 
						header-bg-color="#fff" 
						first-col-bg-color="#fff" 
						content-bg-color="#fff"
						height='182px'
						content-ft-color="#333333"  
						header-weight="true" 
						border-color="#ffffff"
						ref="table" 
						:headers="headers2" 
						:contents="contents2" 
						width="100%"
						:show-vert-border="vertborder"
						:loading="loading"
						:url-col="urlCol"
						@onCheck="onCheck"
						@onCellClick="onCellClick"
						  />			
					</view>
					
				</view>
				<view class="btnPat">
					<button type="default" class="btn" @click="sure">接受</button>
					<button type="default" class="btn" @click="backlast">拒绝</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import wybTable from '@/components/wyb-table/wyb-table.vue'
	import service from '../../service.js';
	import {agreeAllocateMan} from '@/api/request.js';
	import {disagreeAllocateMan} from '@/api/request.js';
	import url from '@/api/url.js';	
	let user=service.getUsers().user;
	export default {
		components: {
			wybTable
		},
		data() {
			const theUrl = '/pages/demos/noticeBar-demo/more' // 本地的某个页面
			const httpUrl = 'https://ext.dcloud.net.cn/plugin?id=2667' // 某个网址
			return {
				url:url,
				heightContent:'',
				swiperHeight: 0,
				//表格
				key: 0,
				username:'',
				str:'',
				object:{},
				taskid:'',
				userid:'',
				headers2:[],
				contents2:[],
				loading:true,
				vertborder:false, //金融竖向条,但是不能去除头部
				// 表格数据
				headers: [{
					label: '商户名称',
					key: 'date',
					width:200,
				}, {
					label: '包裹数量',
					key: 'quantity',
					width:130,
				}, {
					label: '配送人',
					key: 'car',
					width:180,	
				}],
				contents: [
				],
				urlCol: [{
					type: '',
					key: 'id'
				}, {
					type: 'http',
					key: 'url'
				}
				],
			};
		},
		onReady(){
	// 		let that = this
	// 		uni.getSystemInfo({
	// 			success: (res) => { // 需要使用箭头函数，swiper 高度才能设置成功
	// 			// res - 各种参数
	// 			 // 获取屏幕的高度
	// 			// console.log(res.windowHeight);
	// 	　　    let info = uni.createSelectorQuery().select(".wrapper");// 获取某个元素
	// 	　　　  info.boundingClientRect(function(data) { //data - 各种参数
	// 			   // 　console.log(data.top)  // 获取元素高度
	// 				 let view  = res.windowHeight - data.top
	// 				 that.heightContent = view
	// 				 // console.log(that.heightContent)
	// 　　        }).exec()
	// 			}
	// 		});		
		},
		onLoad(options) {
			let json = JSON.parse(decodeURIComponent(options.data));//上级信息
			
			this.object = options
			user=service.getUsers().user;
			this.username = json.fname
			this.userid = json.id
			let list = json.list
			let num = 0;
			for(let i=0;i<list.length;i++){
				let eg ={ id: '5', date: '八号店', quantity: '99', car: '60', listState:true, listColor:[ {"element":2,"color":"#f79c3d"}, ], }
				eg.id = list[i].lineData.id
				eg.date = list[i].lineData.date
				eg.quantity = list[i].lineData.quantity
				eg.car = json.fname
				eg.listState = list[i].lineData.listState
				eg.listColor = list[i].lineData.listColor
				num+=list[i].lineData.quantity
				this.contents.push(eg)
				this.str+=list[i].lineData.shopid+","
				this.taskid+=list[i].lineData.dtdid+","
			}
			// this.contents = name;
			//表格加载动画
			this.wait(1000).then(() => {
				this.headers2 = this.headers.slice()
				this.contents2 = this.contents.slice()
				this.loading = false
			})
			// this.init();
			//表格加载动画
			
		},
		methods: {
			// 返回上一层
			backlast(){
				uni.navigateBack({
					delta: 1
				});
				let pasm={
					id:this.userid,
					text:"对方拒绝了您的请求"
				}
				// this.$store.commit("send",pasm)
				// let  param={
				// 	userid:this.userid,
				// 	id:user.id  
				// };
				// disagreeAllocateMan(param).then(res => {
				// 	if (res.code == 200) {
				// 		uni.navigateBack({
				// 			delta: 1
				// 		});
				// 		let pasm={
				// 			id:this.userid,
				// 			text:"对方拒绝了您的请求"
				// 		}
				// 		this.$store.commit("send",pasm)
				// 	} else{
				// 	}
				// }).catch(err => {
				// 	console.log(err);
				// })
			},
			
			sure(){
				let json = JSON.parse(decodeURIComponent(this.object.data));
				let  param={
					userid:this.userid,
					id:user.id,
					shopid:this.taskid
				};
				agreeAllocateMan(param).then(res => {
					let json = {}
					json.type = '3'
					let pasm={
						id:this.userid,
						text:JSON.stringify(json)
					}
					// this.$store.commit("send",pasm)
					uni.navigateTo({
						url: '/pages/distribution/distribution',
					});
				}).catch(err => {
					console.log(err);
					uni.showModal({
						title: '警告',
						content: '失败',
						showCancel: false
					})
				})
			},
			wait(time) {
				return new Promise(resolve => {
					setTimeout(() => {
						resolve()
					}, time)
				})
			},
		},

	}
</script>

<style scoped>
	.prompt-box-popup {
	  width: 100%;
	  height: 100%;
	  position: fixed;
	  top: 0;
	  bottom: 0;
	  left: 0;
	  right: 0;
	  background: rgba(0, 0, 0, 0.3);
	  z-index: 200;
	 }
	  
	.backs {
		position: absolute;
		z-index: 11111;
		top: 85upx;
		left: 30upx;
		display: flex;
		color: #000;
		line-height: 30upx;
		align-items: center;
		display: inline-block;
	}
	
	.backs image {
		width:45upx;
		height:45upx;
		margin-right: 14upx;
	}

	.titleNview-background {
		width: 100%;
		height: 418upx;
		-webkit-transition: .4s;
		transition: .4s;
		background-size: 100% 100%;
		position: relative;
	}

	.wrapper {
		position: relative;
		width: 91%;
		margin: 0 auto;
		z-index: 2;
		border-top-left-radius:27upx;
		border-top-right-radius:27upx;
		background-color: #fff;
	}
	.pesBtn {
		border-radius: 200upx;
		background-color: #ffc562;
		font-size:28upx;
		color: #fff;
	}
	.pesBtn::after{
		border: none;
	}
	
	/* 表格 */
	.tableBox {
		width: 100%;
		padding-bottom: 40upx;
		margin-top: 44upx;
	}

	.table {
		width: 96%;
		margin: 0 auto;
	}
	
	/*弹窗*/
	.popup-info {
		position: fixed;
		min-width:80%;
		max-width:80%;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		font-size: 30upx;
		border-radius:27upx;
		background-color: #fff;
		z-index: 9999;
	}
	.popuptitle {
		border-top-left-radius: 27upx;
		border-top-right-radius:27upx;
		background-color: #007457;
		height: 98upx;
		width: 100%;
		text-align: center;
		line-height: 98upx;
		color: #fff;
		font-size:36upx;
		letter-spacing: 2px;
	}
	/* 弹窗按钮 */
	.btnPat {
		width:90%;
		margin: 0 5%;
		display: flex;
		flex:1;
		flex-direction:row;
		 justify-content: space-between;
	}
	.btn {
		width:40%;
		background-color: #ffc562;
		border-radius: 200upx;
		margin:40upx auto;
		box-shadow: 0 2px 5px #e3e3e3;
		color: #fff;
	}
	.btn::after{
		border: none;
	}

	
	</style>
